//
//  ThreadDemoControllerViewController.m
//  InterViewQuestions
//
//  Created by flannery on 2020/2/19.
//  Copyright © 2020 flannery. All rights reserved.
//

#import "ThreadDemoControllerViewController.h"

@interface ThreadDemoControllerViewController ()

@end

@implementation ThreadDemoControllerViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
}


- (void)viewdidLoad2{
    [super viewDidLoad];
    //死锁
    dispatch_sync(dispatch_get_main_queue(), ^{
        NSLog(@"deadlock");
    });
    
    dispatch_queue_t serialQueue = dispatch_queue_create("test", DISPATCH_QUEUE_SERIAL);
    dispatch_async(serialQueue, ^{
        dispatch_sync(serialQueue, ^{
            NSLog(@"deadlock");
        });
    });
    
    //换成其他队列
    //dispatch_queue_t seiralQueue = dispatch_queue_create("test", DISPATCH_QUEUE_SERIAL);
    dispatch_queue_t serialQueue2 = dispatch_queue_create("test", DISPATCH_QUEUE_SERIAL);
    
    dispatch_async(serialQueue, ^{
        dispatch_sync(serialQueue2, ^{
            NSLog(@"deadlock");
        });
    });
    
    dispatch_queue_t serialQueue3 = dispatch_queue_create("test", DISPATCH_QUEUE_SERIAL);
    
}






@end
